package design.patterns.mementomode.narrowdemo;

/**
 * @Desc:   测试类
 *
 * @author: cww
 * @DateTime: 2020-06-13 16:49
 */

public class MainTest {

    private static Originator o;
    private static Caretaker c = new Caretaker();

    public static void main(String[] args) {
        // 初次设置发起人状态
        o.setState("On");
        // 将当前发起人状态存入备忘录
        MementoIF mementoIF = o.createMementoIf();
        // 将备忘录赋值给负责人保存
        c.setMementoIF(mementoIF);
        // 改变发起人状态
        o.setState("Off");
        // 还原发起人状态
        o.restoreMemento(c.getMementoIF());
    }
}
